# -*- coding: utf-8 -*-
import numpy as np
from scipy import ndimage
from matplotlib import pylab
from skimage.io import imread

im=imread('vic.png').astype(np.float)#读取图像数据转换为浮点型，不转换得到的效果完全不同
print(np.max(im))
sharpen_kernel=np.array([0,-1,0,-1,5,-1,0,-1,0]).reshape((3,3,1))#自定义卷积层
emboss_kernel=np.array([[-2,-1,0],[-1,1,1],[0,1,2]]).reshape((3,3,1))#自定义卷积层
im_sharp=ndimage.convolve(im,sharpen_kernel,mode='nearest')#对图像进行锐化卷积
im_sharp=np.clip(im_sharp,0,255).astype(np.uint8)
im_emboss=ndimage.convolve(im,emboss_kernel,mode='nearest')#对图像进行浮雕卷积
im_emboss=np.clip(im_emboss,0,255).astype(np.uint8)

#显示图像
pylab.figure(figsize=(10,15))
pylab.subplot(311)
pylab.imshow(im.astype(np.uint8))
pylab.axis('off')
pylab.title('Origial Image',size=25)

pylab.subplot(312)
pylab.imshow(im_sharp)
pylab.axis('off')
pylab.title('Sharpened Image',size=25)

pylab.subplot(313)
pylab.imshow(im_emboss)
pylab.axis('off')
pylab.title('Embossed Image',size=25)
pylab.tight_layout()
pylab.show()




